package com.room.search.domain;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.room.search.domain.enumeration.file.FileType;
import com.room.search.domain.enumeration.file.ImageType;
import com.room.search.domain.vo.AbstractAuditingBuilderEntity;

import javax.persistence.*;
import javax.validation.constraints.Size;

/**
 * Room的文件管理系统
 */
@Entity
@Table(name = "room_file")
@org.springframework.data.elasticsearch.annotations.Document(indexName = "room_file")
public class RoomFile extends AbstractAuditingBuilderEntity<RoomFile> {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private Long id;

    @Size(max = 50)
    @Column(name = "file_name", length = 50)
    @JsonProperty("name")
    private String fileName;

    @Size(max = 10)
    @Column(name = "file_ext", length = 10)
    private String fileExt;

    @Column(name = "file_type", length = 32)
    @Enumerated(EnumType.STRING)
    private FileType fileType;

    @Column(name = "image_type")
    @Enumerated(EnumType.STRING)
    private ImageType imageType;

    @Column(name = "file_remark")
    private String fileRemark;

    @Size(max = 32)
    @Column(name = "file_group", length = 32)
    private String fileGroup;

    @Column(name = "file_path")
    private String filePath;

    @Column(name = "file_url")
    @JsonProperty("url")
    private String fileUrl;

    @ManyToOne
    private RoomCommunity community;

    @ManyToOne
    private RoomGoods goods;


    // jhipster-needle-entity-add-field - JHipster will add fields here

    public Long getId() {
        return this.id;
    }

    public RoomFile id(Long id) {
        this.setId(id);
        return this;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getFileName() {
        return this.fileName;
    }

    public RoomFile fileName(String fileName) {
        this.setFileName(fileName);
        return this;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileExt() {
        return this.fileExt;
    }

    public RoomFile fileExt(String fileExt) {
        this.setFileExt(fileExt);
        return this;
    }

    public void setFileExt(String fileExt) {
        this.fileExt = fileExt;
    }

    public FileType getFileType() {
        return this.fileType;
    }

    public RoomFile fileType(FileType fileType) {
        this.setFileType(fileType);
        return this;
    }

    public void setFileType(FileType fileType) {
        this.fileType = fileType;
    }

    public ImageType getImageType() {
        return this.imageType;
    }

    public RoomFile imageType(ImageType imageType) {
        this.setImageType(imageType);
        return this;
    }

    public void setImageType(ImageType imageType) {
        this.imageType = imageType;
    }

    public String getFileRemark() {
        return this.fileRemark;
    }

    public RoomFile fileRemark(String fileRemark) {
        this.setFileRemark(fileRemark);
        return this;
    }

    public void setFileRemark(String fileRemark) {
        this.fileRemark = fileRemark;
    }

    public String getFileGroup() {
        return this.fileGroup;
    }

    public RoomFile fileGroup(String fileGroup) {
        this.setFileGroup(fileGroup);
        return this;
    }

    public void setFileGroup(String fileGroup) {
        this.fileGroup = fileGroup;
    }

    public String getFilePath() {
        return this.filePath;
    }

    public RoomFile filePath(String filePath) {
        this.setFilePath(filePath);
        return this;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public RoomFile setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
        return this;
    }

    public RoomCommunity getCommunity() {
        return community;
    }

    public RoomFile setCommunity(RoomCommunity community) {
        this.community = community;
        return this;
    }

    public RoomGoods getGoods() {
        return goods;
    }

    public RoomFile setGoods(RoomGoods goods) {
        this.goods = goods;
        return this;
    }



    // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof RoomFile)) {
            return false;
        }
        return id != null && id.equals(((RoomFile) o).id);
    }

    @Override
    public int hashCode() {
        // see https://vladmihalcea.com/how-to-implement-equals-and-hashcode-using-the-jpa-entity-identifier/
        return getClass().hashCode();
    }

    // prettier-ignore


    @Override
    public String toString() {
        return "RoomFile{" +
            "id=" + id +
            ", fileName='" + fileName + '\'' +
            ", fileExt='" + fileExt + '\'' +
            ", fileType=" + fileType +
            ", imageType=" + imageType +
            ", fileRemark='" + fileRemark + '\'' +
            ", fileGroup='" + fileGroup + '\'' +
            ", filePath='" + filePath + '\'' +
            ", fileUrl='" + fileUrl + '\'' +
            ", community=" + community +
            ", goods=" + goods +
            '}';
    }
}
